package cn.liujianbo.example.pattern.strategy.enums;

import java.util.Scanner;

/**
 * @author 刘建波
 * @date 2022-04-02 10:23
 */
public class Test {

    public static void main(String[] args) {
        CashEnum cashEnum = null;

        Scanner scanner = new Scanner(System.in);

        String type = null;
        while (type == null) {
            System.out.println("请输入打折方式（CASH_NORMAL/CASH_REBATE/CASH_RETURN）");
            type = scanner.next();
            cashEnum = CashEnum.valueOf(type);
        }

        double totalPrices = 0;

        System.out.print("请输入单价：");
        double price = scanner.nextDouble();
        System.out.print("请输入数量：");
        double num = scanner.nextDouble();
        totalPrices = cashEnum.acceptCash(price * num);

        System.out.println("单价：" + price + "，数量：" + num + "，类型：" + type + "，合计：" + totalPrices);

        scanner.close();
    }
}
